package org.linlinjava.litemall.db.service;

import java.time.LocalDateTime;
import java.util.List;

import javax.annotation.Resource;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LitemallAdminOrderMerchandiseMapper;
import org.linlinjava.litemall.db.domain.LitemallAdminOrderMerchandise;
import org.linlinjava.litemall.db.domain.LitemallAdminOrderMerchandiseExample;
import org.springframework.stereotype.Service;

@Service
public class LitemallAdminOrderMerchandiseService extends MPJBaseServiceImpl<LitemallAdminOrderMerchandiseMapper,LitemallAdminOrderMerchandise> {
    @Resource
    private LitemallAdminOrderMerchandiseMapper adminOrderMerchandiseMapper;


    public void insert(LitemallAdminOrderMerchandise adminOrderMerchandise) {
        adminOrderMerchandise.setAddTime(LocalDateTime.now());
        adminOrderMerchandise.setUpdateTime(LocalDateTime.now());
        adminOrderMerchandiseMapper.insertSelective(adminOrderMerchandise);
    }

    public void update(LitemallAdminOrderMerchandise adminOrderMerchandise) {
    	adminOrderMerchandise.setUpdateTime(LocalDateTime.now());
    	adminOrderMerchandiseMapper.updateByPrimaryKey(adminOrderMerchandise);
    }

    public List<LitemallAdminOrderMerchandise> querybyAdminOrderId(Integer adminOrderId) {
        LitemallAdminOrderMerchandiseExample example = new LitemallAdminOrderMerchandiseExample();
        example.or().andAdminOrderIdEqualTo(adminOrderId);
        return adminOrderMerchandiseMapper.selectByExample(example);
}

    public LitemallAdminOrderMerchandise getbyAdminOrderIdAndMerchandiseId(Integer adminOrderId, Integer merchandiseId) {
    	LitemallAdminOrderMerchandiseExample example = new LitemallAdminOrderMerchandiseExample();
    	example.or().andAdminOrderIdEqualTo(adminOrderId).andMerchandiseIdEqualTo(merchandiseId);
    	return adminOrderMerchandiseMapper.selectByExample(example).get(0);
    }
}
